package com.zipking.cloud.springbootmybatis.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Slf4j
@Component
public class QueueListener {

    @Autowired
    private DoorOpeningRecordTask doorOpeningRecordTask;

    /**
     * 初始化时启动监听请求队列
     */
    //@PostConstruct
    public void init() {
        log.info("任务已启动");
        doorOpeningRecordTask.start();
    }

    /**
     * 销毁容器时停止监听任务
     */
    @PreDestroy
    public void destory() {
        log.info("销毁容器时停止监听任务");
        doorOpeningRecordTask.interrupt();
    }

}

